package com.group9.config;

import com.group9.interceptor.MyIntercptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

//在启动的时候就会被加载
@Configuration
public class InterceptorConfigurer implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 如果有多个拦截器，分别执行addInterceptor即可
        // /**  webapp目录下除了jsp不拦截，其他都拦截
        registry.addInterceptor(new MyIntercptor()).addPathPatterns("/**").excludePathPatterns(excludePathList());;
    }
    public List<String> excludePathList(){
        List<String> listUrls = new ArrayList<String>();
        // 对哪些地址不拦截
        listUrls.add("/userinfo/login");      //登录页

        //网站静态资源
        listUrls.add("/css/**");
        listUrls.add("/js/**");
        listUrls.add("/fonts/**");
        listUrls.add("/images/**");
        return listUrls;
    }
}
